<?php

abstract class XB_Config_Abstract {
	protected $_configs = array();
	
	protected abstract function parseXml($tag,$file);
	
	protected abstract function parseIni($tag, $file);
	
	public function parseFile($tag,$file){
		if($this->testConfigsArray($tag)){return ;}
		$fileStringArray = explode('.',$file);
		$type = $fileStringArray[sizeof($fileStringArray)-1];
		switch ($type) {
			case 'xml':
				return $this->parseXml($tag,$file);
			break;
			case 'ini':
				return $this->parseIni($tag,$file);
			break;
			default:
				throw new Exception('TYPE ERROR');
			break;
		}
	}
	
	public function removeconfig($tag){
		unset($this->_configs[$tag]);
	}
	
	protected function testConfigsArray($tag){
		if(isset($this->_configs[$tag])){
			return true;
		}else{
			return false;
		}
	}
	
	protected function setConfigsArray($tag,$config){
		if(!$this->testConfigsArray($tag)){
			$this->_configs[$tag] = $config;
			return ;
		}
	}
	
	public function getConfig($tag){
		
		if(!isset($this->_configs[$tag])){
			throw new Exception('EMPTY CONFIG');
			return ;
		}
		return $this->_configs[$tag];
	}
}

?>